import requests


class IhrmApi:

    # 登录接口
    @classmethod
    def emp_login_api(cls, body):
        url = "http://ihrm2-test.itheima.net/api/sys/login"
        head = {"Content-Type": "application/json"}
        resp = requests.post(url, headers=head, json=body)
        return resp

    # 添加员工接口
    @classmethod
    def emp_add_api(cls, token, body):
        url = "http://ihrm2-test.itheima.net/api/sys/user"
        head = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.post(url, headers=head, json=body)
        return resp

    # 修改员工接口
    @classmethod
    def emp_put_api(cls, empId, token, body):
        url = "http://ihrm2-test.itheima.net/api/sys/user/"+empId
        head = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.put(url, headers=head, json=body)
        return resp

    # 查询员工接口
    @classmethod
    def emp_query_api(cls, empId, token):
        url = "http://ihrm2-test.itheima.net/api/sys/user/"+empId
        head = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.get(url, headers=head)
        return resp

    # 删除员工接口
    @classmethod
    def emp_delete_api(cls, empId, token):
        url = "http://ihrm2-test.itheima.net/api/sys/user/"+empId
        head = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.delete(url, headers=head)
        return resp




if __name__ == '__main__':
    a = IhrmApi.emp_login_api({"mobile": "13800000002","password": "123456"})
    print(a.json())
    a = IhrmApi.emp_add_api("c6c47505-a530-4256-9119-f8e2813c3121",
                            {"username": "小猪佩奇",
                             "mobile": "13200000555",
                             "workNumber": "225134562132452"}
                            )
    print(a.json())
    # a = IhrmApi.emp_put_api("1563362278059814912",
    #                         "1b7ac6dc-dad7-41fa-b31d-5967b3ad9958",
    #                         {"username": "齐天大圣"})
    # print(a.json())
    # a = IhrmApi.emp_query_api("1563362278059814912",
    #                         "1b7ac6dc-dad7-41fa-b31d-5967b3ad9958")
    # print(a.json())
    # a = IhrmApi.emp_delete_api("1563362278059814912",
    #                         "1b7ac6dc-dad7-41fa-b31d-5967b3ad9958")
    # print(a.json())
    #




